package org.ggn.init;


import org.ggn.dao.CourseDao;
import org.ggn.dao.GradeDao;
import org.ggn.model.Course;
import org.ggn.model.Grade;
import org.ggn.util.HibernateUtil;
import org.hibernate.Session;

public class InitCourse {
	
	public static void main(String[] args) {
		Session session = null;
		try {
			session = HibernateUtil.openSession();
			session.beginTransaction();

			Grade g3 = new Grade("大二上");
			session.save(g3);
			Course c1 = new Course("概率论与数理统计","gllysltj_",g3);
			session.save(c1);
			Course c2 = new Course("离散结构","lsjg_",g3);
			session.save(c2);
			Course c3 = new Course("JAVA","java_",g3);
			session.save(c3);
			Course c4 = new Course("大学物理A","dxwlA_",g3);
			session.save(c4);
			Course c5 = new Course("大学英语III","dxyyIII_",g3);
			session.save(c5);
			Course c6 = new Course("数据通讯","sjtx_",g3);
			session.save(c6);

			session.getTransaction().commit();
		} 
		finally{
			HibernateUtil.close(session);
		}
	}
	public void addg1(){
		GradeDao gd = new GradeDao();
		CourseDao cd = new CourseDao();
		Grade g1 = gd.load(1);
		Course c1 = new Course("高等数学AI","gdsxAI_",g1);
		Course c2 = new Course("C语言","cyy_",g1);
		Course c3 = new Course("计算机导论","jsjdl_",g1);
		Course c4 = new Course("大学英语I","dxyyI_",g1);
		Course c5 = new Course("思修","sx_",g1);
		Course c6 = new Course("军事理论","jsll_",g1);
		Course c7 = new Course("应用文写作","yywxz_",g1);
		cd.add(c1);cd.add(c2);cd.add(c3);cd.add(c4);cd.add(c5);cd.add(c6);cd.add(c7);
		
		/*
		 * Grade g1 = new Grade("大一上");
			session.save(g1);
			Course c1 = new Course("高等数学AI","gdsxAI_",g1);
			session.save(c1);
			Course c2 = new Course("C语言","cyy_",g1);
			session.save(c2);
			Course c3 = new Course("计算机导论","jsjdl_",g1);
			session.save(c3);
			Course c4 = new Course("大学英语I","dxyyI_",g1);
			session.save(c4);
			Course c5 = new Course("思修","sx_",g1);
			session.save(c5);
			Course c6 = new Course("军事理论","jsll_",g1);
			session.save(c6);
			Course c7 = new Course("应用文写作","yywxz_",g1);
			session.save(c7);
			
		 */
	}
	public void addg2(){
		GradeDao gd = new GradeDao();
		CourseDao cd = new CourseDao();
		Grade g2 = gd.load(2);
		Course c1 = new Course("高等数学AII","gdsxAII_",g2);
		Course c2 = new Course("数据结构","sjjg_",g2);
		Course c3 = new Course("数字逻辑","szlj_",g2);
		Course c4 = new Course("大学英语II","dxyyII_",g2);
		Course c5 = new Course("近代史纲要","jdsgy_",g2);
		cd.add(c1);cd.add(c2);cd.add(c3);cd.add(c4);cd.add(c5);
		/**
		 * Grade g2 = new Grade("大一下");
			session.save(g2);
			Course c1 = new Course("高等数学AII","gdsxAII_",g2);
			session.save(c1);
			Course c2 = new Course("数据结构","sjjg_",g2);
			session.save(c2);
			Course c3 = new Course("数字逻辑","szlj_",g2);
			session.save(c3);
			Course c4 = new Course("大学英语II","dxyyII_",g2);
			session.save(c4);
			Course c5 = new Course("近代史纲要","jdsgy_",g2);
			session.save(c5);
			
		 */
	}
	public void addg3(){
		GradeDao gd = new GradeDao();
		CourseDao cd = new CourseDao();
		Grade g3 = gd.load(3);
		Course c1 = new Course("概率论与数理统计","gllysltj_",g3);
		Course c2 = new Course("离散结构","lsjg_",g3);
		Course c3 = new Course("JAVA","java_",g3);
		Course c4 = new Course("大学物理A","dxwlA_",g3);
		Course c5 = new Course("大学英语III","dxyyIII_",g3);
		Course c6 = new Course("数据通讯","sjtx_",g3);
		cd.add(c1);cd.add(c2);cd.add(c3);cd.add(c4);cd.add(c5);cd.add(c6);
		/**
		 * Grade g3 = new Grade("大二上");
			session.save(g3);
			Course c1 = new Course("概率论与数理统计","gllysltj_",g3);
			session.save(c1);
			Course c2 = new Course("离散结构","lsjg_",g3);
			session.save(c2);
			Course c3 = new Course("JAVA","java_",g3);
			session.save(c3);
			Course c4 = new Course("大学物理A","dxwlA_",g3);
			session.save(c4);
			Course c5 = new Course("大学英语III","dxyyIII_",g3);
			session.save(c5);
			Course c6 = new Course("数据通讯","sjtx_",g3);
			session.save(c6);
		 */
	}
}
